package handler

import (
	"encoding/json"
	"github.com/gin-gonic/gin"
	"post-hub/inits"
	"post-hub/internal/dto"
	"post-hub/internal/model"
	"post-hub/response"
	"time"
)

func ShowUser(c *gin.Context) {

	var user model.User
	err := c.ShouldBind(&user)
	if err != nil {
		response.Error(c, "解析失败")
		return
	}
	err = dto.ShowUser(&user, int(user.ID))
	if err != nil {
		response.Error(c, "查看失败")
		return
	}
	response.Success(c, "查看成功", user)
	marshal, err := json.Marshal(&user)
	if err != nil {
		return
	}
	inits.Rdb.Set(inits.Ctx, "video", marshal, time.Minute*3)
}
